home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / include / sys / shm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-20  |  5.8 KB  |  198 lines

  1. /*     @(#)shm.h    4.1.1.2    (ULTRIX)    12/9/88     */
  2.  
  3. /************************************************************************
  4.  *                                    *
  5.  *            Copyright (c) 1986 by                *
  6.  *        Digital Equipment Corporation, Maynard, MA        *
  7.  *            All rights reserved.                *
  8.  *                                    *
  9.  *   This software is furnished under a license and may be used and    *
  10.  *   copied  only  in accordance with the terms of such license and    *
  11.  *   with the  inclusion  of  the  above  copyright  notice.   This    *
  12.  *   software  or  any  other copies thereof may not be provided or    *
  13.  *   otherwise made available to any other person.  No title to and    *
  14.  *   ownership of the software is hereby transferred.            *
  15.  *                                    *
  16.  *   This software is  derived  from  software  received  from  the    *
  17.  *   University    of   California,   Berkeley,   and   from   Bell    *
  18.  *   Laboratories.  Use, duplication, or disclosure is  subject  to    *
  19.  *   restrictions  under  license  agreements  with  University  of    *
  20.  *   California and with AT&T.                        *
  21.  *                                    *
  22.  *   The information in this software is subject to change  without    *
  23.  *   notice  and should not be construed as a commitment by Digital    *
  24.  *   Equipment Corporation.                        *
  25.  *                                    *
  26.  *   Digital assumes no responsibility for the use  or  reliability    *
  27.  *   of its software on equipment which is not supplied by Digital.    *
  28.  *                                    *
  29.  ************************************************************************/
  30. /*
  31.  *
  32.  *   Modification history:
  33.  *
  34.  * 3 Mar 88 -- jaa
  35.  *    added smsmat to sminfo, which is now the configurable
  36.  *    highest attachable address for shared mem
  37.  *
  38.  * 27 Jan 87 -- depp
  39.  *    Cleaned up some of the incompatibilities between SYSTEM V and
  40.  *    ULTRIX-32 naming conventions
  41.  *
  42.  * 29 Apr 86 -- depp
  43.  *    Moved some shared memory constants from param.h to here, except 
  44.  *    SMMIN, SMMAX, SMBRK which are configurable.  The defaults
  45.  *    for these 3 constants is in /sys/conf/param.c.  Plus, the data
  46.  *    element "small" removed from struct sminfo.
  47.  *
  48.  * 18 Mar 86 -- depp
  49.  *    Changed struct smem.  The sm_daddr member is now a pointer rather
  50.  *    than an array, so that an array can be dynamically allocated to
  51.  *    handle any size request.
  52.  *
  53.  * 18 Sep 85 -- depp
  54.  *    Added SMNOSW flag and sm_lcount for page locking
  55.  *
  56.  * 08 April 85 -- depp
  57.  *    New file for System V shared memory
  58.  *
  59.  */
  60.  
  61. /*
  62. **    IPC Shared Memory Facility.
  63. */
  64.  
  65. /*
  66. **    Implementation Constants.
  67. */
  68.  
  69.             /* segment low boundary address multiple */
  70.             /* (SMLBA must be a power of 2) */
  71. #ifdef vax
  72. #define    SMLBA    ctob(CLSIZE)
  73. #endif vax
  74. #ifdef mips
  75. #define SMLBA   ctob(NPTEPG)
  76. #endif mips
  77.  
  78.  
  79.             /* for SYSTEM V compatibility        */
  80. #define    SHMLBA        SMLBA
  81.  
  82. /*
  83. **    Permission Definitions.
  84. */
  85.  
  86. #define    SM_R    0400    /* read permission */
  87. #define    SM_W    0200    /* write permission */
  88.  
  89.             /* for SYSTEM V compatibility        */
  90. #define SHM_R    SM_R
  91. #define SHM_W    SM_W
  92.  
  93. /*
  94. **    ipc_perm Mode Definitions.
  95. */
  96.  
  97. #define    SM_CLEAR    01000    /* clear segment on next attach */
  98. #define    SM_DEST        02000    /* destroy seg when # attached = 0 */
  99.  
  100.             /* for SYSTEM V compatibility        */
  101. #define SHM_INIT    SM_CLEAR
  102. #define SHM_DEST    SM_DEST
  103.  
  104. /*
  105. **    Message Operation Flags.
  106. */
  107.  
  108. #define    SM_RDONLY    010000    /* attach read-only (else read-write) */
  109. #define    SM_RND        020000    /* round attach address to SHMLBA */
  110.  
  111.             /* for SYSTEM V compatibility        */
  112. #define SHM_RDONLY    SM_RDONLY
  113. #define SHM_RND        SM_RND
  114.  
  115. /*
  116.  *  sizing constant (the balance are in /sys/h/param.h and /sys/conf/param.c.
  117.  */
  118. #define    SMMNI    100       /* Max number SM segments in system */
  119.  
  120. /*
  121. **    Structure Definitions.
  122. */
  123.  
  124.  
  125. /*
  126. **    There is a shared mem id struct for each segment in the system.
  127. */
  128.  
  129.  
  130. struct smem {
  131.                 /* SM_PERM must be the first    */
  132.                 /* element in the structure.    */
  133.     struct ipc_perm    sm_perm;    /* permission struct */
  134.     swblk_t    *sm_daddr;     /* disk addrs of DMTEXT page segs */
  135.     swblk_t    sm_ptdaddr;    /* disk address of page table */
  136.     size_t    sm_size;    /* segment size (bytes) */
  137.     struct proc *sm_caddr;    /* ptr to linked proc, if loaded */
  138.     struct pte *sm_ptaddr;    /* ptr to assoc page table */
  139.     short    sm_rssize;    /* SM resource set size (pages)    */
  140.     ushort sm_lpid;        /* pid of last smop */
  141.     ushort sm_cpid;        /* pid of creator */
  142.     char    sm_count;    /* reference count */
  143.     char    sm_ccount;    /* number of loaded references */
  144.     short    sm_lcount;    /* number of processes locking SMS */
  145.     short    sm_flag;    /* traced, written flags */
  146.     short    sm_poip;    /* page out in progress count */
  147.     time_t    sm_atime;    /* last smat time */
  148.     time_t    sm_dtime;    /* last smdt time */
  149.     time_t    sm_ctime;    /* last change time */
  150. };
  151.             /* for SYSTEM V compatibility        */
  152. #define shmid_ds    smem
  153. #define key_t        long
  154. #define shm_perm    sm_perm
  155. #define shm_segsz    sm_size
  156. #define shm_cpid    sm_cpid
  157. #define shm_lpid    sm_lpid
  158. #define shm_nattch    sm_count
  159. #define shm_atime    sm_atime
  160. #define shm_dtime    sm_dtime
  161. #define shm_ctime    sm_ctime
  162.  
  163.  
  164. /* NOTE:  These values must align with X* flag values in text.h */
  165. #define    SMLOCK    010        /* Being swapped in or out */
  166. #define    SMWANT    020        /* Wanted for swapping */
  167. #define SMNOSW    0100        /* Lock segment in memory */
  168.  
  169. /* shared memory specific commands for shmctl syscall */
  170. #define SHM_LOCK    3    /* Lock segment in memory */
  171. #define SHM_UNLOCK    4    /* Unlock segment in memory */
  172.  
  173. /*
  174.  * sminfo structure is used by the system for bounds checking.  All of 
  175.  * the elements in this structure are initialized in /sys/conf/param.c.
  176.  *
  177.  * Three of the elements are configurable via the "config" program
  178.  * (smmax, smmin, smbrk).  If they are not config'ed, then they all
  179.  * have defaults.
  180.  */  
  181. struct sminfo {
  182.     int    smmax,    /* max shared memory segment size */
  183.         smmin,    /* min shared memory segment size */
  184.         smmni,    /* # of shared memory identifiers */
  185.         smseg,    /* max attached shared memory segs per proc */
  186.         smbrk,    /* gap (in clicks) used between data and SM */
  187.             smsmat; /* max shmem attach addr (clicks) */
  188. };
  189.  
  190.             /* for SYSTEM V compatibility */
  191. #define shminfo        sminfo
  192. #define shmmax        smmax
  193. #define shmmin        smmin
  194. #define shmmni        smmni
  195. #define shmseg        smseg
  196. #define shmbrk        smbrk
  197.  
  198.